/**
 * Licensee: DuKe TeAm
 * License Type: Purchased
 */
package ormsamples;

import org.orm.*;
public class RetrieveAndUpdateTaller21Data {
	public void retrieveAndUpdateTestData() throws PersistentException {
		PersistentTransaction t = orm.Taller21PersistentManager.instance().getSession().beginTransaction();
		try {
			orm.DAOFactory lDAOFactory = orm.DAOFactory.getDAOFactory();
			orm.dao.PacienteDAO lormPacienteDAO = lDAOFactory.getPacienteDAO();
			orm.Paciente lormPaciente = lormPacienteDAO.loadPacienteByQuery(null, null);
			// Update the properties of the persistent object
			lormPacienteDAO.save(lormPaciente);
			orm.dao.PrestacionDAO lormPrestacionDAO = lDAOFactory.getPrestacionDAO();
			orm.Prestacion lormPrestacion = lormPrestacionDAO.loadPrestacionByQuery(null, null);
			// Update the properties of the persistent object
			lormPrestacionDAO.save(lormPrestacion);
			orm.dao.DiagnosticoDAO lormDiagnosticoDAO = lDAOFactory.getDiagnosticoDAO();
			orm.Diagnostico lormDiagnostico = lormDiagnosticoDAO.loadDiagnosticoByQuery(null, null);
			// Update the properties of the persistent object
			lormDiagnosticoDAO.save(lormDiagnostico);
			t.commit();
		}
		catch (Exception e) {
			t.rollback();
		}
		
	}
	
	public void retrieveByCriteria() throws PersistentException {
		System.out.println("Retrieving Paciente by PacienteCriteria");
		orm.PacienteCriteria pacienteCriteria = new orm.PacienteCriteria();
		// Please uncomment the follow line and fill in parameter(s)
		//pacienteCriteria.pa_id_paciente.eq();
		System.out.println(pacienteCriteria.uniquePaciente());
		
		System.out.println("Retrieving Prestacion by PrestacionCriteria");
		orm.PrestacionCriteria prestacionCriteria = new orm.PrestacionCriteria();
		// Please uncomment the follow line and fill in parameter(s)
		//prestacionCriteria.pr_id_prestacion.eq();
		System.out.println(prestacionCriteria.uniquePrestacion());
		
		System.out.println("Retrieving Diagnostico by DiagnosticoCriteria");
		orm.DiagnosticoCriteria diagnosticoCriteria = new orm.DiagnosticoCriteria();
		// Please uncomment the follow line and fill in parameter(s)
		//diagnosticoCriteria.di_id_diagnostico.eq();
		System.out.println(diagnosticoCriteria.uniqueDiagnostico());
		
	}
	
	
	public static void main(String[] args) {
		try {
			RetrieveAndUpdateTaller21Data retrieveAndUpdateTaller21Data = new RetrieveAndUpdateTaller21Data();
			try {
				retrieveAndUpdateTaller21Data.retrieveAndUpdateTestData();
				//retrieveAndUpdateTaller21Data.retrieveByCriteria();
			}
			finally {
				orm.Taller21PersistentManager.instance().disposePersistentManager();
			}
		}
		catch (Exception e) {
			e.printStackTrace();
		}
	}
}
